package com.wanchuang.shengfubao.view.machines;

import android.view.View;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wanchuang.shengfubao.R;

import org.jetbrains.annotations.NotNull;

public class RootNodeProvider extends BaseNodeProvider {

    @Override
    public int getItemViewType() {
        return 0;
    }

    @Override
    public int getLayoutId() {
        return R.layout.def_section_marchines_head;
    }

    @Override
    public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
        // 数据类型需要自己强转
        FirstNode entity = (FirstNode) data;
//        helper.setVisible(R.id.line, !entity.isExpanded());
        helper.setText(R.id.tv_gc_name, entity.getData());
        if (entity.isExpanded()) {
            helper.setBackgroundResource(R.id.iv_changes, R.mipmap.icon_down2);
        } else {
            helper.setBackgroundResource(R.id.iv_changes, R.mipmap.icon_right2);
        }
//        if (entity.getPosition() % 2 == 0) {
//            helper.<RRelativeLayout>getView(R.id.rv_root).getHelper().setBackgroundColorNormal(Color.parseColor("#FFD5896B"));
//        } else {
//            helper.<RRelativeLayout>getView(R.id.rv_root).getHelper().setBackgroundColorNormal(Color.parseColor("#FF65A9BC"));
//        }

    }

    @Override
    public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) {
        getAdapter().expandOrCollapse(position);
    }
}